Skip to content

Conversation

@joch
Copy link
Member

@joch joch commented Nov 4, 2025

Problem

The SDK failed to compile with error:

src/opperai/sdk.py:252:9: E0602: Undefined variable 'models' (undefined-variable)

This was caused by a naming collision between:

  • The models package (for data types/models)
  • A new Models SDK class (for model alias management)

Root Cause

When the new model alias endpoints (/models/aliases/*) were added to the API, they were missing the x-speakeasy-group: language_models override in the Speakeasy overlay configuration. This caused Speakeasy to generate a separate Models SDK class in models_.py, creating a conflict with the existing from opperai import models package import.

Solution

Added x-speakeasy-group: language_models to all 6 model alias endpoints in .speakeasy/speakeasy-modifications-overlay.yaml:

  • create_alias
  • list_aliases
  • get_alias
  • update_alias
  • delete_alias
  • get_alias_by_name

This unifies all model operations under the LanguageModels SDK class, eliminating the naming conflict.

Changes

  • ✅ Modified .speakeasy/speakeasy-modifications-overlay.yaml with missing group overrides
  • ✅ Deleted src/opperai/models_.py (conflicting Models SDK)
  • ✅ All model alias methods now in language_models.py
  • ✅ SDK compiles successfully
  • ✅ Version bumped to 1.6.3
  • ✅ Added new rerank functionality from latest API updates

Testing

  • SDK generation completes without errors
  • Python compilation passes (python -m py_compile)
  • Pylint passes with 10/10 rating
  • All custom patches applied successfully

Release Notes

This fix resolves a critical compilation error and should be released ASAP. After merge, the automated release workflow will publish v1.6.3 to PyPI.

Fixes compilation error caused by naming collision between the models
package and the Models SDK class.

Root cause:
- New model alias endpoints (/models/aliases/*) were missing the
  x-speakeasy-group override
- Speakeasy generated separate Models class in models_.py
- Created conflict: `from opperai import models` vs `self.models: "Models"`
- Result: pylint error "undefined variable 'models'" in sdk.py:252

Solution:
- Added x-speakeasy-group: language_models to all 6 alias endpoints:
  * create_alias, list_aliases, get_alias
  * update_alias, delete_alias, get_alias_by_name
- All model operations now unified under LanguageModels SDK
- Eliminated models_.py and naming conflict

Changes:
- Modified .speakeasy/speakeasy-modifications-overlay.yaml
- Deleted src/opperai/models_.py
- All model alias methods moved to language_models.py
- SDK compiles successfully, version bumped to 1.6.3
@joch joch merged commit 318d3ac into main Nov 4, 2025
1 check passed
@joch joch deleted the fix/model-alias-naming-conflict branch November 4, 2025 14:35
Copy link

@agentobot agentobot bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Opper Python SDK – PR #109 Review

Area Observation Recommendation
Naming-conflict fix Deleted src/opperai/models_.py and grouped alias endpoints via x-speakeasy-group. Build now passes. ✅ Looks good – resolves compile error.
Parameter rename embeddings.py (input_input) shadows Python built-in. Non-blocking: consider input_data for clarity & to keep built-in usable.
Dataclass immutability Error classes changed from frozen=True to unsafe_hash=True, making them mutable. Ensure no code relies on previous immutability; otherwise fine.
OAuth2 scopes Default oauth2_scopes arg switched from []None. 👍 Cleaner default; no issues.
Docs & version Extensive doc regeneration and version bump 1.3.0 → 1.6.4. Confirm downstream clients pin >=1.6.4 before release.

Overall the patch is solid, fixes the blocking compile issue, and introduces helpful rerank & alias docs. Suggestions above are non-blocking.

Status: Approving – great work!

Reviewed by agentobot[bot]

Copy link

@agentobot agentobot bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Addendum – Minor Follow-Up Suggestions

Area Observation Recommendation
Version bump text _version.py sets __version__ = "1.6.4", while PR body mentions 1.6.3 Update PR description or bump note to 1.6.4 so changelog matches code.
Error mapping entries.py handles 400/401/404/422/500 but omits 409 & 429 Consider mapping HTTP 409 (Conflict) and 429 (Rate Limit) to existing ConflictError / custom error for completeness.
Built-in shadowing embeddings.py uses parameter name input Non-blocking: rename to input_data to avoid masking built-in input().

These are non-blocking and do not affect approval status already granted. Thanks for the quick fix!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants